#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>

int main(int argc, char** argv)
{
	if(argc < 3)
	{
		printf("input <%s 源文件 目标文件>", argv[0]);
		return -1;
	}
	int fd = open(argv[1],O_RDONLY);
	if(fd == -1)
	{
		perror(argv[1]);
		return -1;
	}
	int fd2 = open(argv[2],O_WRONLY | O_CREAT | O_APPEND,0644);
	if(fd2 == -1)
	{
		perror(argv[2]);
		return -1;
	}
	char s[1024] = {0};
	while(read(fd,s,sizeof(s)))
	{
		write(fd2,s,sizeof(s));
		memset(s,0,sizeof(s));
	}
	close(fd);
	close(fd2);
	return 0;
}
